package com.restaurantonlineorder.seller.controller;

import com.restaurantonlineorder.response.BaseResult;
import com.restaurantonlineorder.seller.service.IOrderService;
import com.restaurantonlineorder.seller.vo.req.OrderReqVo;
import com.restaurantonlineorder.seller.vo.resp.OrderRespVo;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;

/**
 * @author 熊宇
 * @date 2022/7/23 15:28
 * @description
 */
@RestController
@Validated
@RequestMapping("/order")
public class OrderController {


    @Resource
    private IOrderService iOrderService;

    /**
     * 查看订单
     */
    @GetMapping("/order")
    public BaseResult<OrderRespVo> queryOrder(Long id) {
        OrderRespVo orderInfo = iOrderService.getOrderInfo(id);
        return BaseResult.success(orderInfo);
    }

    /**
     * 生成订单
     *
     * @param orderReqVo
     * @return
     */
    @PostMapping("/generate-order")
    public BaseResult generateOrder(@Valid @RequestBody OrderReqVo orderReqVo) {

        return iOrderService.createOrder(orderReqVo);
    }

}
